package com.iwop.moto.comm;
import java.io.Serializable;
import java.util.List;
public class Page<T> implements Serializable{
	/**
	 * 当前页
	 */
	private int pageIndex=1;
	/**
	 * 总记录数
	 */
	private int pageCount=0;
	/**
	 * 起始查询位置
	 */
	private int startIndex;
	/**
	 * 结束查询位置
	 */
	private int endIndex;
	
	/**
	 * 每页显示多少条默认10条
	 */
	private int pageSize=10;
	
	/**
	 * 总记录数
	 */
	private int recordCount;
	private int curRecordCount=0;
	/**
	 * 数据
	 */
	private List<T> list;

	public Page() {

		super();
	}
	public Page(int pageIndex,int pageSize){
		this.pageIndex=pageIndex;
		this.pageSize=pageSize;
		startIndex=(pageIndex-1)*pageSize;
		endIndex=pageSize;//pageIndex*pageSize;
	}
	
	public int getPageIndex() {
		return pageIndex;
	}
	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}
	public int getPageCount() {
		pageCount = (recordCount + pageSize - 1) / pageSize;
		return pageCount;
	}
	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
		this.setCurRecordCount(list!=null?list.size():0);
	}
	public int getStartIndex() {
		return startIndex;
	}
	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}
	public int getEndIndex() {
		return endIndex;
	}
	public void setEndIndex(int endIndex) {
		this.endIndex = endIndex;
	}

	public int getRecordCount() {
		/*if(recordCount<pageSize){
			pageCount=1;
		}*/
		//pageCount=recordCount/pageSize;
		pageCount = (recordCount + pageSize - 1) / pageSize;
		return recordCount;
	}

	public void setRecordCount(int recordCount) {
		pageCount = (recordCount + pageSize - 1) / pageSize;
		this.recordCount = recordCount;
	}

	public int getCurRecordCount() {
		return curRecordCount;
	}

	public void setCurRecordCount(int curRecordCount) {
		this.curRecordCount = curRecordCount;
	}
}
